<?php

namespace app\admin\model;


class Role extends Base
{
    /**
     * @return array
     * 数据验证规则
     */
    public function filedRules(){
        return [
            "action"=>["add","update","status","delete"],
            "form"=>[
                'id|id|用户ID|update|status|delete' => 'require|minNumber:2',
                'role_name|role_name|角色名|add|update'=>'require',
                'nickname|nickname|昵称|add|update'=>'require',
                'ids|role|权限ID|add|update'=>'normal',
                'remark|remark|备注|add|update'=>'normal',
                'status|status|用户状态|add|update|status'=>'require|number',
            ],
        ];
    }
    /**
     * @return array
     * 搜索验证规则
     */
    public  function searchRule(){
        return [
            "index"=>[],
        ];
    }
    /**
     * 获取列表数据
     *
    */
    public function GetRoleLists()
    {
        $where[]=["is_del","=","0"];
        $where[]=["id",">","1"];
        $data = $this->where($where)->select() ->toArray();
        return $data;
    }

    /**
     * 添加/编辑 角色
     *
     *
     */
    public function addEdit($data = [],$id){
        if(!empty($id))
        {
            $this->update($data, ['id' => $id]);
        }
        else
        {
            $this->insert($data);
        }
    }
}